<template>
	<div id="comming">
		<div class="commingToward">近期最受期待</div>
		<ul class="towardUl">
			<li v-for="toward in coming" :key="toward.id" class="towardClass">
				<div class="towardImg">
					<img :src="picFix(toward.img)" />
				</div>	
				<div class="towardXin"><img src="../../../../image/下载 (10).png"/>	</div>
				<div class="towardWish">{{toward.wish}}人想看</div>
				<div class="towardNm">{{toward.nm}}</div>
				<!-- <div v-if="toward.comingTitle.length>10" class="towardDate" >{{toward.comingTitle.slice(0,10)}}</div>
				<div class="towardDate" v-else="">{{toward.comingTitle.slice(0,7)}}</div> -->
				<div class="towardDate">{{toward.comingTitle}}</div>
			</li>
		</ul>
		<ul>
			<li v-for="toUnder in com" :key="toUnder.id" class="toUnderLi">
				<div class="commingToward">{{toUnder.comingTitle}}</div>
				<div class="toUnder_content clearfix">
					<div class="contentLeft"><img :src="picFix(toUnder.img)"/></div>
					<div class="contentRight">
						<div class="contentNm">{{toUnder.nm}}</div>
						<div class="contentWish"><span>{{toUnder.wish}}</span>人想看</div>
						<div class="contentStar">主演:{{toUnder.star}}</div>
						<div class="contentRt">{{toUnder.rt}}上映</div>
					</div>
					<button v-if="toUnder.showst==4" class="pre">预售</button>
					<button  v-else="" class="button_mai"  style="background: #faaf00;">想看</button>
				</div>
			</li>
		</ul>
	</div>
</template>

<script>
		export default {

  created(){
  				//电影详情
			this.axios.get('/maoyan/ajax/mostExpected',{
				params:{
					ci: 20,
					limit: 10,
					offset: 0,
					token:''
				},
			}).then((res)=>{
				console.log(res.data)
				//进入里面的comin数据
				this.coming=res.data.coming
				
			
			})
			
			this.axios.get('/maoyan/ajax/comingList',{
				params:{
					ci: 20,
					token: '',
					limit: 10
				}
			}).then((res)=>{
				console.log("即将上映下面那parth",res.data)
				this.com =res.data.coming;
				
				//遍历数组所有的成员，以成员的某个数据作为分组的组名，
				//在添加前，先判断对象上的属性，（组名）是否存在，若不存在则设置一个空数组
				//将成员添加到对应的属性（组）上
				this.coming.forEach((item)=>{
					if (!this.fenzu[item.comingTitle]) {
						this.fenzu[item.comingTitle]=[]		
					}
				
				this.fenzu[item.comingTitle].push(item)
				})
				
				
			})
			},
	data(){
		return {
			coming:[],		
			com:[],
			fenzu:{
				'周四':[],
			
			}
			
		}
		
	},
	methods:{
		picFix(url){
			if (typeof url=='string') {
					return url.replace('w.h','170.230')
			}
		
		},
	
	}
	}
</script>

<style>
</style>